<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>main—index-TL</title>
		<!-- css代码 start -->
		<link href="../../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../../css/global.css" rel="stylesheet" />
		<link href="../../../../css/style.css" rel="stylesheet" />
		<style>
			.mui-radio input[type=radio]{
				left: 0;
				top: 6px;
			}
			.mui-checkbox label, .mui-radio label{
				padding-left: 38px;
				font-size: 14px;
				color: #333333;
				padding-right: 0;
			}
			.md_item .l_txt{
				height: auto;
			}
		</style>
		<!-- css代码 end -->
	</head>
	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">MD相关问题</h1>
		</header>
		<div class="mui-content">
			<div hidden>
				<input type="hidden" id="id" />
				<input type="hidden" id="serviceNo" />
				<input type="hidden" id="enginnerId" />
				<input type="hidden" id="helpId" />
			</div>
			<div class="page_cen shadow zp_cen">
				<div class="md_item autoHeight">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesOne" value="1" type="radio" class="rds" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesOne" value="0" type="radio" class="rds" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span>*</span>1.是否导致或可能导致人员（患者、操作者、其他人员）伤害?
					</div>
				</div>
				<div class="md_item autoHeight">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesTwo" value="1" type="radio" class="rds" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesTwo" value="0" type="radio" class="rds" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span>*</span>2.是否导致或可能导致错误的病情诊断结果?
					</div>
				</div>
				<div class="md_item autoHeight">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesThree" value="1" type="radio" class="rds" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesThree" value="0" type="radio" class="rds" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span>*</span>3.是否导致或可能导致患者的样本失效或数据丢失?
					</div>
				</div>
				<div class="md_item autoHeight">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesFour" value="1" type="radio" class="rds" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesFour" value="0" type="radio" class="rds" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span>*</span>4.是否导致或可能导致延误病情诊断?
					</div>
				</div>
				<div class="md_item autoHeight">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesFive" value="1" type="radio" class="rds" onclick="quesFiveChange()" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesFive" value="0" type="radio" class="rds" onclick="quesFiveChange()" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span>*</span>5.是否是设备故障？（故障是指部分元器件功能失效而导致整个医疗器械功能恶化的事件）
					</div>
				</div>
				<div class="md_item autoHeight" id="quesFiveoneDiv" style="display: none;">
					<div class="r_radio">
						<div class="mui-input-row mui-radio">
							<input name="quesFiveone" value="1" type="radio" class="rds" />
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio">
							<input name="quesFiveone" value="0" type="radio" class="rds" />
							<label>否</label>
						</div>
					</div>
					<div class="l_txt">
						<span></span>如本次故障没有伤害，但故障再次发生，是否可能导致死亡或严重伤害
					</div>
				</div>
			</div>
			<div class="btn_box">
				<span id="cancale" class="fl">取消</span>
				<span id="saveBtn" class="fr red">保存</span>
			</div>
			<div style="height: 50px;"></div>
		</div>
		<!-- html代码 end -->

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/utils/h.js"></script>
		<script src="../../../../js/constant.js"></script>
		<script src="../../../../js/common.js"></script>
		<script src="../../../../js/utils/base64.js"></script>
		<script src="../../../../js/utils/md5.js"></script>
		<script src="../../../../js/utils/sortMap.js"></script>
		<script src="../../../../js/utils/http.js"></script>
		<script src="../../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			/**
			 * 第五个问题事件改变监听
			 */
			function quesFiveChange() {
				if (JS.GetRadioValue('quesFive') == '1') {
					h('#quesFiveoneDiv').show()
				} else if (JS.GetRadioValue('quesFive') == '0') {
					h('#quesFiveoneDiv').hide()
					JS.ClearRadioChecked('quesFiveone')
				}
			}

			// 提交状态 0未提交 1已提交
			var submitStatus = 0;

			(function($, doc) {
				$.init();

				$.plusReady(function() {
					var self = plus.webview.currentWebview()
					var wo = self.opener()
					submitStatus = self.submitStatus;
					if (submitStatus == '1') {
						h('.rds').attr('disabled', 'disabled')
						h('#saveBtn').hide()
						h('#cancale').hide()
					}
					h('#id').val(self.serviceReportId)
					h('#serviceNo').val(self.serviceNo)
					h('#enginnerId').val(self.enginnerId)
					h('#helpId').val(self.helpId)
					var quesOne = self.quesOne;
					if (quesOne && quesOne != "null") {
						document.querySelector(`input[name='quesOne'][value='${quesOne}']`).checked = true;
					}
					var quesTwo = self.quesTwo;
					if (quesTwo && quesTwo != "null") {
						document.querySelector(`input[name='quesTwo'][value='${quesTwo}']`).checked = true;
					}
					var quesThree = self.quesThree;
					if (quesThree && quesThree != "null") {
						document.querySelector(`input[name='quesThree'][value='${quesThree}']`).checked = true;
					}
					var quesFour = self.quesFour;
					if (quesFour && quesFour != "null") {
						document.querySelector(`input[name='quesFour'][value='${quesFour}']`).checked = true;
					}
					var quesFive = self.quesFive;
					if (quesFive && quesFive != "null") {
						document.querySelector(`input[name='quesFive'][value='${quesFive}']`).checked = true;
					}
					if (quesFive == '1') {
						h('#quesFiveoneDiv').show()
					}
					var quesFiveone = self.quesFiveone;
					if (quesFiveone && quesFiveone != "null") {
						document.querySelector(`input[name='quesFiveone'][value='${quesFiveone}']`).checked = true;
					}

					// 保存按钮事件
					h('#saveBtn').tap(function() {
						if (!app.getNetworkState()) {
							app.toast("无网络")
							return
						}

						var id = h('#id').val()
						var serviceNo = h('#serviceNo').val()
						var helpId = h('#helpId').val()
						var quesOne = JS.GetRadioValue('quesOne')
						var quesTwo = JS.GetRadioValue('quesTwo')
						var quesThree = JS.GetRadioValue('quesThree')
						var quesFour = JS.GetRadioValue('quesFour')
						var quesFive = JS.GetRadioValue('quesFive')
						var quesFiveone = JS.GetRadioValue('quesFiveone')

						if (!quesOne || !quesTwo || !quesThree || !quesFour || !quesFive) {
							app.toast('请回答所有问题')
							return
						}
						if (quesFive == '1' && !quesFiveone) {
							app.toast('请回答所有问题')
							return
						}
						if (quesFive == '0') {
							quesFiveone = ""
						}

						var enginnerId = app.getUser().enginnerId
						var fseName = app.getUser().name;
						var params = {
							id,
							serviceNo,
							helpId,
							quesOne,
							quesTwo,
							quesThree,
							quesFour,
							quesFive,
							quesFiveone,
							enginnerId,
							fseName
						}
						
						app.showWaiting('正在保存...')
						ajaxPost(BASE_URL + 'cc/service/report/editMdQuestion', params, function(data) {
							app.closeWaiting()
							if (data.code === 200) {
								app.toast("保存成功")
								wo.evalJS('updateMd(' + data.data.id + ', ' + enginnerId + ', ' + quesOne + ', ' + quesTwo + ', ' + quesThree + ',' +
									quesFour + ', ' + quesFive + ', ' + quesFiveone + ')')
								mui.back()
							} else {
								if (data.msg) {
									app.toast(data.msg)
								} else {
									app.toast()
								}
							}
						}, function(errorMsg) {
							app.closeWaiting()
							app.toast(errorMsg)
						})
					})

					// 取消按钮事件
					h('#cancale').tap(function() {
						$.back()
					})
				});
			}(mui, document));
		</script>
		<!-- js代码 end -->
	</body>
</html>
